function [c1,c2] = smooth_it(c1,c2,v1,v2,v3,v4,d,r)
% smooth_it(c1,c2,v1,v2,v3,v4,d,r)
% calculate the smoothness condition of 2 triangles, with c^0 and c^1
% modify the parameter c1


[cr,desc,asce] = get_auxillary_mat(d);

line1 = cr_indices(0,d,1,cr);
line2 = cr_indices(0,d,-1,cr);
% the length(line*) = d-r+1;
% and the value of the position is stored in line$

% then treat the c^0 condition:
if r>=0
    c2(line2) = c1(line1); % change the parameter of surface 2
end

% treat the C^1 condition more:
line11 = cr_indices(1,d,1,cr);
line22 = cr_indices(1,d,-1,cr);
if r>=1
    % comput the barycentric coordinate of v4 relative to T1
    A = [1 1 1; v1(1) v2(1) v3(1); v1(2) v2(2) v3(2)];
    b = [1 v4(1) v4(2)]';
    tau = A\b;
    c2(line22) = [c1(line11) c1(line1(1:end-1)) c1(line1(2:end))] * tau;
end